using System;
using System.Collections.Generic;
using System.Text;
using Rapier.Kodachi.Shared;
using Microsoft.Win32;
using System.IO;
using System.Xml.Serialization;
using System.Drawing;

namespace Rapier.Kodachi.Firefox
{
    public class FirefoxPlugin : Plugin
    {
        #region Properties
        private static FirefoxSettings _FirefoxSettings;
        public static FirefoxSettings FirefoxSettings
        {
            get { return _FirefoxSettings; }
        }
        #endregion

        #region Data Members
        private FirefoxCatalog catalog;
        #endregion

        #region Constructor
        public FirefoxPlugin(Host host)
            : base(host)
        {
            LoadSettings();
            catalog = new FirefoxCatalog(this);
        }
        #endregion

        #region Overrides
        public override string Author
        {
            get { return "El Guapo"; }
        }

        public override string Url
        {
            get { return "http://www.rapiersoftware.com"; }
        }

        public override bool HasSettings
        {
            get { return true; }
        }

        public override bool ShowSettings()
        {
            Settings settings = new Settings(Host);
            settings.ShowDialog();

            return true;
        }

        public override void SaveSettings()
        {
            Host.DataManager.SaveSettings(this, FirefoxSettings);
        }

        private void LoadSettings()
        {
            _FirefoxSettings = Host.DataManager.LoadSettings<FirefoxSettings>(this);
            if (FirefoxSettings == null)
            {
                _FirefoxSettings = new FirefoxSettings();
                FirefoxSettings.UseDefault = true;
                FirefoxSettings.SpecificFirefoxProfilePath = "Browse...";
            }
        }

        public override void UpdateDatabase()
        {
            // TODO: Add items here (copy code from CoreCatalog)
            catalog.LoadItems();
        }
        #endregion
    }
}
